// 统计连续正确和连续错误的段落长度
function calculateConsecutiveCounts(data) {
	let consecutiveCorrect = [];    // 存储连续正确（1）的段长度
	let consecutiveIncorrect = [];  // 存储连续错误（0）的段长度
	let count = 1;                  // 当前段的长度，初始为1
  
	// 遍历数据，统计连续正确和错误的段落
	for (let i = 1; i < data.length; i++) {
	  if (data[i] === data[i - 1]) {
		count++;
	  } else {
		if (data[i - 1] === 1) {
		  consecutiveCorrect.push(count);
		} else {
		  consecutiveIncorrect.push(count);
		}
		count = 1; // 重置计数
	  }
	}
  
	// 处理最后一段
	if (data[data.length - 1] === 1) {
	  consecutiveCorrect.push(count);
	} else {
	  consecutiveIncorrect.push(count);
	}
  
	return { consecutiveCorrect, consecutiveIncorrect };
  }

module.exports = calculateConsecutiveCounts;
